package com.inibb.app.util.mail;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class PCCWEMailData {

	// Refactoring: should use HashMap to replace individual properties
	private String to;
	private String from;
	private String subject;
	private String text;
	private String template;
	private List<String> cc = new ArrayList<String>();
	private List<StreamAttachmentDataSource> streamAttachmentList;
	private List<File> fileAttachmentList;

	public String getTo() {
		return to;
	}

	public void setTo(String to) {
		this.to = to;
	}

	public String getFrom() {
		return from;
	}

	public void setFrom(String from) {
		this.from = from;
	}

	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public String getTemplate() {
		return template;
	}

	public void setTemplate(String template) {
		this.template = template;
	}

	public List<StreamAttachmentDataSource> getStreamAttachmentList() {
		return streamAttachmentList;
	}

	public void setStreamAttachmentList(
		List<StreamAttachmentDataSource> streamDataSourceList) {
		this.streamAttachmentList = streamDataSourceList;
	}

	public List<File> getFileAttachmentList() {
		return fileAttachmentList;
	}

	public void setFileAttachmentList(List<File> fileList) {
		this.fileAttachmentList = fileList;
	}

	public boolean isAttachmentExist() {
		return (isStreamAttachmentExist() || isFileAttachmentExist());
	}

	public boolean isFileAttachmentExist() {
		return (fileAttachmentList != null && !fileAttachmentList.isEmpty());
	}

	public boolean isStreamAttachmentExist() {
		return (streamAttachmentList != null && !streamAttachmentList.isEmpty());
	}

	public boolean isTemplateExist() {
		return (template.length() > 0);
	}

	public String toString() {
		StringBuffer buffer = new StringBuffer();

		buffer.append("To : " + getTo() + ", ").append(
				"From : " + getFrom() + ", ").append(
				"Subject : " + getSubject() + ", ").append(
				"Text : " + getText() + ", ");
		
		if (isStreamAttachmentExist()) {
			for (StreamAttachmentDataSource streamAttachment : streamAttachmentList) {
				buffer.append("Stream Attachment : " + streamAttachment.getName() + ", ");
			}
		}
		
		if (isFileAttachmentExist()) {
			for (File fileAttachment : fileAttachmentList) {
				buffer.append("File Attachment : " + fileAttachment.getName() + ", ");
			}
		}
		
		return buffer.toString();
	}

	public List<String> getCc() {
		return cc;
	}

	public void setCc(List<String> cc) {
		this.cc = cc;
	}


}
